package phone_utils

import (
	"errors"
	"fmt"
	"hft/Database/admin"
	"hft/Database/admin/user_db"
	"hft/e"
	"hft/global"
)

// 找出城市
func FindCity(cityName string) (data *admin.Region, err error) {
	var city *admin.Region
	if err := global.OC_DB.Where("name LIKE ?", fmt.Sprintf("%v%%", cityName)).Where("level = ?", "city").First(&city).Error; err != nil {
		return nil, errors.New(e.RegionNotFound)
	} else {
		return city, nil
	}
}

// 创建线索
func CreateClue(list []*user_db.Clue, data *user_db.PhoneRecord) (info []*user_db.Clue) {
	var clue = &user_db.Clue{
		OriginType:  3,
		PhoneRecord: *data,
	}
	list = append(list, clue)
	return list
}

// 生成跟进记录
func CreateFollowUp(list []*user_db.FollowUp, ManagerName string) []*user_db.FollowUp {
	list = append(list, &user_db.FollowUp{
		Cont: fmt.Sprintf("[%v]领取了客户", ManagerName),
	})
	return list
}
